<!DOCTYPE HTML>
<html>

<head>
	<link rel="bookmark"  type="image/x-icon"  href="/img/logo_miccall.png"/>
	<link rel="shortcut icon" href="/img/logo_miccall.png">
	
			    <title>
    Ame雨
    </title>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no" />
    <link rel="stylesheet" href="/amelin-ting/css/mic_main.css" />
    <link rel="stylesheet" href="/amelin-ting/css/dropdownMenu.css" />
    <meta name="keywords" content="Ame雨" />
    
    	<script async src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>
	 
    <noscript>
        <link rel="stylesheet" href="/amelin-ting/css/noscript.css" />
    </noscript>
    <style type="text/css">
        body:before {
          content: ' ';
          position: fixed;
          top: 0;
          background: url('/amelin-ting/img/bg.jpg') center 0 no-repeat;
          right: 0;
          bottom: 0;
          left: 0;
          background-size: cover; 
        }
    </style>

			    
  
    <script type="text/x-mathjax-config">
      MathJax.Hub.Config({
        tex2jax: {
          inlineMath: [ ['$','$'], ["\\(","\\)"]  ],
          processEscapes: true,
          skipTags: ['script', 'noscript', 'style', 'textarea', 'pre', 'code']
        }
      });
    </script>

    <script type="text/x-mathjax-config">
      MathJax.Hub.Queue(function() {
        var all = MathJax.Hub.getAllJax(), i;
        for (i=0; i < all.length; i += 1) {
          all[i].SourceElement().parentNode.className += ' has-jax';
        }
      });
    </script>
    <script async type="text/javascript" src="//cdn.bootcss.com/mathjax/2.7.1/latest.js?config=TeX-AMS-MML_HTMLorMML"></script>
  


    <script src="/amelin-ting/js/jquery.min.js"></script>
    <script src="/amelin-ting/js/jquery.scrollex.min.js"></script>
    <script src="/amelin-ting/js/jquery.scrolly.min.js"></script>
    <script src="/amelin-ting/js/skel.min.js"></script>
    <script src="/amelin-ting/js/util.js"></script>
    <script src="/amelin-ting/js/main.js"></script>
	
<meta name="generator" content="Hexo 5.4.0"></head>
    
		
<!-- Layouts -->



<!--  代码渲染  -->
<link rel="stylesheet" href="/css/prism_coy.css" />
<link rel="stylesheet" href="/css/typo.css" />
<!-- 文章页 -->
<body class="is-loading">
    <!-- Wrapper 外包 s-->
    <div id="wrapper" class="fade-in">
        <!-- Intro 头部显示 s -->
        <!-- Intro 头部显示 e -->
        <!-- Header 头部logo start -->
        <header id="header">
    <a href="/amelin-ting/" class="logo">Art Space</a>
</header>
        <!-- Nav 导航条 start -->
        <nav id="nav" class="special" >
            <ul class="menu links" >
			<!-- Homepage  主页  --> 
			<li >
	            <a href="/amelin-ting/" rel="nofollow">主页</a>
	        </li>
			<!-- categories_name  分类   --> 
	        
	        <li class="active">
	            <a href="#s1">分类</a>
	                    <ul class="submenu">
	                        <li>
	                        <a class="category-link" href="/amelin-ting/categories/Go/">Go</a></li><li><a class="category-link" href="/amelin-ting/categories/django/">django</a></li><li><a class="category-link" href="/amelin-ting/categories/drf/">drf</a></li><li><a class="category-link" href="/amelin-ting/categories/gin/">gin</a></li><li><a class="category-link" href="/amelin-ting/categories/go/">go</a></li><li><a class="category-link" href="/amelin-ting/categories/linux/">linux</a></li><li><a class="category-link" href="/amelin-ting/categories/mysql/">mysql</a></li><li><a class="category-link" href="/amelin-ting/categories/python/">python</a></li><li><a class="category-link" href="/amelin-ting/categories/%E5%86%85%E7%BD%91%E7%A9%BF%E9%80%8F/">内网穿透</a></li><li><a class="category-link" href="/amelin-ting/categories/%E5%89%8D%E7%AB%AF/">前端</a>
	                    </ul>
	        </li>
	        
	        <!-- archives  归档   --> 
	        
	        
		        <!-- Pages 自定义   -->
		        
		        <li>
		            <a href="/about/" title="简历">
		                简历
		            </a>
		        </li>
		        
		        <li>
		            <a href="/group/" title="团队">
		                团队
		            </a>
		        </li>
		        
		        <li>
		            <a href="/gallery/" title="图库">
		                图库
		            </a>
		        </li>
		        
		        <li>
		            <a href="/tag/" title="标签">
		                标签
		            </a>
		        </li>
		        


            </ul>
            <!-- icons 图标   -->
			<ul class="icons">
                    
                    <li>
                        <a title="github" href="https://github.com/miccall" target="_blank" rel="noopener">
                            <i class="icon fa fa-github"></i>
                        </a>
                    </li>
                    
                    <li>
                        <a title="500px" href="http://500px.com" target="_blank" rel="noopener">
                            <i class="icon fa fa-500px"></i>
                        </a>
                    </li>
                    
			</ul>
</nav>

        <div id="main" >
            <div class ="post_page_title_img" style="height: 25rem;background-image: url(https://img1.baidu.com/it/u=2743367680,3364101188&amp;fm=26&amp;fmt=auto);background-position: center; background-repeat:no-repeat; background-size:cover;-moz-background-size:cover;overflow:hidden;" >
                <a href="#" style="padding: 4rem 4rem 2rem 4rem ;"><h2 >drf Serializer</h2></a>
            </div>
            <!-- Post -->
            <div class="typo" style="padding: 3rem;">
                <h2 id="一、序列化器Serializer"><a href="#一、序列化器Serializer" class="headerlink" title="一、序列化器Serializer"></a>一、序列化器Serializer</h2><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br></pre></td><td class="code"><pre><span class="line"><span class="number">1.</span> 序列化组件介绍</span><br><span class="line">    <span class="string">&quot;&quot;&quot;</span></span><br><span class="line"><span class="string">        序列化，序列化会把模型对象转换成字典，经过response以后变成json字符串。</span></span><br><span class="line"><span class="string">        反序列化，把客户端发送过来的数据，经过request以后变成字典，序列化器可以把字典变成模型</span></span><br><span class="line"><span class="string">        反序列化，完成数据校验功能</span></span><br><span class="line"><span class="string">    &quot;&quot;&quot;</span></span><br><span class="line"></span><br><span class="line">    </span><br><span class="line"><span class="number">2.</span> 简单流程</span><br><span class="line">    <span class="string">&quot;&quot;&quot;</span></span><br><span class="line"><span class="string">        写一个序列化的类,继承Serializer</span></span><br><span class="line"><span class="string">        在类中写要序列化的字段</span></span><br><span class="line"><span class="string">        在视图类中使用，导入——&gt;实例化得到一个对象，要把要序列化的对象传入</span></span><br><span class="line"><span class="string">        序列化的对象.data 是一个字典</span></span><br><span class="line"><span class="string">        将字典返回，如果使用rest_framework提供的Response，就得使用JsonResponse，而且setting注册应用的&quot;rest_framework&quot;也可以注释	</span></span><br><span class="line"><span class="string">    &quot;&quot;&quot;</span></span><br><span class="line">    </span><br><span class="line"><span class="number">3.</span> 代码演示</span><br><span class="line">    <span class="comment"># models 创建一个书表</span></span><br><span class="line">        <span class="keyword">from</span> django.db <span class="keyword">import</span> models</span><br><span class="line">        <span class="comment"># Create your models here.</span></span><br><span class="line">        <span class="class"><span class="keyword">class</span> <span class="title">Book</span>(<span class="params">models.Model</span>):</span></span><br><span class="line">            title = models.CharField(max_length=<span class="number">32</span>)</span><br><span class="line">            price = models.DecimalField(max_digits=<span class="number">6</span>, decimal_places=<span class="number">2</span>)</span><br><span class="line">            author = models.CharField(max_length=<span class="number">32</span>)</span><br><span class="line">            publish = models.CharField(max_length=<span class="number">32</span>)</span><br><span class="line"></span><br><span class="line">    <span class="comment"># 在应用下面创建一个py文件，名字任意</span></span><br><span class="line">        <span class="keyword">from</span> rest_framework <span class="keyword">import</span> serializers</span><br><span class="line">        <span class="class"><span class="keyword">class</span> <span class="title">BookSerialezer</span>(<span class="params">serializers.Serializer</span>):</span></span><br><span class="line">            <span class="built_in">id</span> = serializers.CharField()</span><br><span class="line">            title = serializers.CharField()</span><br><span class="line">            price = serializers.CharField()</span><br><span class="line">            author = serializers.CharField()</span><br><span class="line">            publish = serializers.CharField()</span><br><span class="line"></span><br><span class="line">    <span class="comment"># url</span></span><br><span class="line">        <span class="keyword">from</span> django.conf.urls <span class="keyword">import</span> url</span><br><span class="line">        <span class="keyword">from</span> django.contrib <span class="keyword">import</span> admin</span><br><span class="line">        <span class="keyword">from</span> app01 <span class="keyword">import</span> views</span><br><span class="line">        urlpatterns = [</span><br><span class="line">            url(<span class="string">r&#x27;^books/(?P&lt;pk&gt;\d+)&#x27;</span>, views.BookViews.as_view())</span><br><span class="line">        ]</span><br><span class="line"></span><br><span class="line">    <span class="comment"># views</span></span><br><span class="line">        <span class="keyword">from</span> django.shortcuts <span class="keyword">import</span> render</span><br><span class="line">        <span class="keyword">from</span> rest_framework.views <span class="keyword">import</span> APIView</span><br><span class="line">        <span class="keyword">from</span> app01.models <span class="keyword">import</span> Book</span><br><span class="line">        <span class="keyword">from</span> app01.ser <span class="keyword">import</span> BookSerialezer</span><br><span class="line">        <span class="keyword">from</span> rest_framework.response <span class="keyword">import</span> Response</span><br><span class="line">        <span class="comment"># Create your views here.</span></span><br><span class="line">        <span class="class"><span class="keyword">class</span> <span class="title">BookViews</span>(<span class="params">APIView</span>):</span></span><br><span class="line">            <span class="function"><span class="keyword">def</span> <span class="title">get</span>(<span class="params">self, request, pk</span>):</span></span><br><span class="line">                book = Book.objects.<span class="built_in">filter</span>(<span class="built_in">id</span>=pk).first()</span><br><span class="line">                book_ser = BookSerialezer(book)</span><br><span class="line">                <span class="keyword">return</span> Response(book_ser.data)</span><br><span class="line"></span><br></pre></td></tr></table></figure>

<h2 id="二、序列化组件修改数据"><a href="#二、序列化组件修改数据" class="headerlink" title="二、序列化组件修改数据"></a>二、序列化组件修改数据</h2><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br></pre></td><td class="code"><pre><span class="line"><span class="string">&quot;&quot;&quot;</span></span><br><span class="line"><span class="string">    写一个序列化的类，继承Serializer</span></span><br><span class="line"><span class="string">    在类中写要反序列化的字段，像反序列化那个字段，就在类中写哪个租店，字段的属性(max_lenth......)</span></span><br><span class="line"><span class="string">            max_length	最大长度</span></span><br><span class="line"><span class="string">            min_lenght	最小长度</span></span><br><span class="line"><span class="string">            allow_blank	是否允许为空</span></span><br><span class="line"><span class="string">            trim_whitespace	是否截断空白字符</span></span><br><span class="line"><span class="string">            max_value	最小值</span></span><br><span class="line"><span class="string">            min_value	最大值</span></span><br><span class="line"><span class="string">    在视图类中使用，导入———&gt;实例化得到序列化类的对象，把要要修改的对象传入，修改的数据传入</span></span><br><span class="line"><span class="string">            boo_ser=BookSerializer(book,request.data)</span></span><br><span class="line"><span class="string">            boo_ser=BookSerializer(instance=book,data=request.data)</span></span><br><span class="line"><span class="string">    数据校验 if boo_ser.is_valid()	</span></span><br><span class="line"><span class="string">    如果校验通过 就保存 boo_ser.save()  # 注意不是book.save()</span></span><br><span class="line"><span class="string">    如果不通过 逻辑自己补</span></span><br><span class="line"><span class="string">    如果字段的校验规则不够，可以写钩子函数(局部和全局)</span></span><br><span class="line"><span class="string">    也可以使用字段的author=serializers.CharField(validators=[check_author])来校验</span></span><br><span class="line"><span class="string">	-写一个函数</span></span><br><span class="line"><span class="string">    	def check_author(data):</span></span><br><span class="line"><span class="string">            if data.startswith(&#x27;sb&#x27;):</span></span><br><span class="line"><span class="string">                raise ValidationError(&#x27;作者名字不能以sb开头&#x27;)</span></span><br><span class="line"><span class="string">            else:</span></span><br><span class="line"><span class="string">                return data</span></span><br><span class="line"><span class="string">     -配置：validators=[check_author]</span></span><br><span class="line"><span class="string">&quot;&quot;&quot;</span></span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="number">1.</span>代码演示</span><br><span class="line">	<span class="comment"># models</span></span><br><span class="line">        <span class="keyword">from</span> django.db <span class="keyword">import</span> models</span><br><span class="line">        <span class="comment"># Create your models here.</span></span><br><span class="line">        <span class="class"><span class="keyword">class</span> <span class="title">Book</span>(<span class="params">models.Model</span>):</span></span><br><span class="line">            title = models.CharField(max_length=<span class="number">32</span>)</span><br><span class="line">            price = models.DecimalField(max_digits=<span class="number">6</span>, decimal_places=<span class="number">2</span>)</span><br><span class="line">            author = models.CharField(max_length=<span class="number">32</span>)</span><br><span class="line">            publish = models.CharField(max_length=<span class="number">32</span>)</span><br><span class="line">            </span><br><span class="line">	<span class="comment"># views</span></span><br><span class="line">        <span class="class"><span class="keyword">class</span> <span class="title">BookViews</span>(<span class="params">APIView</span>):</span></span><br><span class="line">            <span class="function"><span class="keyword">def</span> <span class="title">get</span>(<span class="params">self, request, pk</span>):</span></span><br><span class="line">                book_obj = Book.objects.<span class="built_in">filter</span>(<span class="built_in">id</span>=pk).first()</span><br><span class="line">                book_ser = BookSerialezer(book_obj)</span><br><span class="line">                <span class="keyword">return</span> Response(book_ser.data)</span><br><span class="line"></span><br><span class="line">            <span class="function"><span class="keyword">def</span> <span class="title">put</span>(<span class="params">self, request, pk</span>):</span></span><br><span class="line">                <span class="comment"># 建立返回报错字典</span></span><br><span class="line">                back_dir = &#123;<span class="string">&#x27;code&#x27;</span>: <span class="number">200</span>, <span class="string">&#x27;msg&#x27;</span>: <span class="string">&#x27;成功&#x27;</span>&#125;</span><br><span class="line">                <span class="comment"># 直接拿到书的对象</span></span><br><span class="line">                book_obj = Book.objects.<span class="built_in">filter</span>(<span class="built_in">id</span>=pk).first()</span><br><span class="line">                <span class="comment"># 实例化一个序列化类的对象</span></span><br><span class="line">                book_ser = BookSerialezer(book_obj, request.data)</span><br><span class="line">                <span class="keyword">if</span> book_ser.is_valid():</span><br><span class="line">                    book_ser.save()</span><br><span class="line">                <span class="keyword">else</span>:</span><br><span class="line">                    back_dir[<span class="string">&#x27;code&#x27;</span>] = <span class="number">300</span></span><br><span class="line">                    back_dir[<span class="string">&#x27;msg&#x27;</span>] = <span class="string">&#x27;数据检验不正确&#x27;</span></span><br><span class="line">                    back_dir[<span class="string">&#x27;data&#x27;</span>] = book_ser.errors</span><br><span class="line">                <span class="keyword">return</span> Response(back_dir)</span><br><span class="line">            </span><br><span class="line">	<span class="comment"># 在应用下面创建一个py文件，名字任意</span></span><br><span class="line">            <span class="keyword">from</span> rest_framework.exceptions <span class="keyword">import</span> ValidationError</span><br><span class="line">            <span class="keyword">from</span> rest_framework <span class="keyword">import</span> serializers</span><br><span class="line">            </span><br><span class="line">            <span class="class"><span class="keyword">class</span> <span class="title">BookSerialezer</span>(<span class="params">serializers.Serializer</span>):</span></span><br><span class="line">                title = serializers.CharField(max_length=<span class="number">8</span>, min_length=<span class="number">3</span>)</span><br><span class="line">                price = serializers.CharField()</span><br><span class="line">                author = serializers.CharField(validators=[check_author])</span><br><span class="line">                publish = serializers.CharField()</span><br><span class="line">                </span><br><span class="line">                <span class="function"><span class="keyword">def</span> <span class="title">check_author</span>(<span class="params">data</span>):</span></span><br><span class="line">                    <span class="keyword">if</span> data.startswith(<span class="string">&#x27;sb&#x27;</span>):</span><br><span class="line">                        <span class="keyword">raise</span> ValidationError(<span class="string">&#x27;作者名字不能以sb开头&#x27;</span>)</span><br><span class="line">                    <span class="keyword">else</span>:</span><br><span class="line">                        <span class="keyword">return</span> data</span><br><span class="line">            </span><br><span class="line">                <span class="comment"># 局部钩子</span></span><br><span class="line">                <span class="function"><span class="keyword">def</span> <span class="title">validate_price</span>(<span class="params">self, data</span>):</span></span><br><span class="line">                    <span class="keyword">if</span> <span class="built_in">float</span>(data) &gt; <span class="number">10</span>:</span><br><span class="line">                        <span class="keyword">return</span> data</span><br><span class="line">                    <span class="keyword">else</span>:</span><br><span class="line">                        <span class="keyword">raise</span> ValidationError(<span class="string">&#x27;价格太低&#x27;</span>)</span><br><span class="line">				</span><br><span class="line">                <span class="comment"># 全局钩子</span></span><br><span class="line">                <span class="function"><span class="keyword">def</span> <span class="title">validate</span>(<span class="params">self, validate_data</span>):</span></span><br><span class="line">                    <span class="built_in">print</span>(validate_data)</span><br><span class="line">                    author = validate_data.get(<span class="string">&#x27;author&#x27;</span>)</span><br><span class="line">                    publish = validate_data.get(<span class="string">&#x27;publish&#x27;</span>)</span><br><span class="line">                    <span class="keyword">if</span> author == publish:</span><br><span class="line">                        <span class="keyword">raise</span> ValidationError(<span class="string">&#x27;不能一样&#x27;</span>)</span><br><span class="line">                    <span class="keyword">else</span>:</span><br><span class="line">                        <span class="keyword">return</span> validate_data</span><br><span class="line">			   <span class="comment"># 重新写update方法</span></span><br><span class="line">                <span class="function"><span class="keyword">def</span> <span class="title">update</span>(<span class="params">self, instance, validated_data</span>):</span></span><br><span class="line">                    instance.title = validated_data.get(<span class="string">&#x27;title&#x27;</span>)</span><br><span class="line">                    instance.price = validated_data.get(<span class="string">&#x27;price&#x27;</span>)</span><br><span class="line">                    instance.author = validated_data.get(<span class="string">&#x27;author&#x27;</span>)</span><br><span class="line">                    instance.publish = validated_data.get(<span class="string">&#x27;publish&#x27;</span>)</span><br><span class="line">                    instance.save()</span><br><span class="line">                    <span class="keyword">return</span> instance</span><br><span class="line">                </span><br><span class="line">	<span class="comment"># urls.py</span></span><br><span class="line">        re_path(<span class="string">&#x27;books/(?P&lt;pk&gt;\d+)&#x27;</span>, views.BookView.as_view()),</span><br></pre></td></tr></table></figure>

<h2 id="三、read-only-amp-write-only"><a href="#三、read-only-amp-write-only" class="headerlink" title="三、read only &amp; write only"></a>三、read only &amp; write only</h2><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><span class="line"><span class="number">1.</span> read only </span><br><span class="line">	表明该字段仅用于序列化输出，默认<span class="literal">False</span>，如果设置为<span class="literal">True</span>，postman中可以看到该字段，修改时，不需要传该字段。</span><br><span class="line"><span class="number">2.</span> write_only </span><br><span class="line">	表明该字段仅用于反序列化输入，默认<span class="literal">False</span>，如果设置成<span class="literal">True</span>，postman中看不到该字段，修改时，该字段需要传。</span><br><span class="line">    </span><br><span class="line"><span class="string">&quot;&quot;&quot;</span></span><br><span class="line"><span class="string">以下的了解</span></span><br><span class="line"><span class="string">    required	表明该字段在反序列化时必须输入，默认True</span></span><br><span class="line"><span class="string">    default	反序列化时使用的默认值</span></span><br><span class="line"><span class="string">    allow_null	表明该字段是否允许传入None，默认False</span></span><br><span class="line"><span class="string">    validators	该字段使用的验证器</span></span><br><span class="line"><span class="string">    error_messages	包含错误编号与错误信息的字典</span></span><br><span class="line"><span class="string">&quot;&quot;&quot;</span>   </span><br><span class="line"></span><br></pre></td></tr></table></figure>

<h2 id="四、查询所有数据"><a href="#四、查询所有数据" class="headerlink" title="四、查询所有数据"></a>四、查询所有数据</h2><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># urls.py</span></span><br><span class="line">    <span class="keyword">from</span> django.conf.urls <span class="keyword">import</span> url</span><br><span class="line">    <span class="keyword">from</span> django.contrib <span class="keyword">import</span> admin</span><br><span class="line">    <span class="keyword">from</span> app01 <span class="keyword">import</span> views</span><br><span class="line">    urlpatterns = [</span><br><span class="line">        url(<span class="string">r&#x27;^books/&#x27;</span>, views.BooksViews.as_view())</span><br><span class="line">    ]</span><br><span class="line"></span><br><span class="line"><span class="comment"># views.py</span></span><br><span class="line">    <span class="class"><span class="keyword">class</span> <span class="title">BooksViews</span>(<span class="params">APIView</span>):</span></span><br><span class="line">        <span class="function"><span class="keyword">def</span> <span class="title">get</span>(<span class="params">self, request</span>):</span></span><br><span class="line">            <span class="comment"># 建立返回字典</span></span><br><span class="line">            response_msg = &#123;<span class="string">&#x27;status&#x27;</span>: <span class="number">200</span>, <span class="string">&#x27;msg&#x27;</span>: <span class="string">&#x27;成功&#x27;</span>&#125;</span><br><span class="line">            <span class="comment"># 建立书本对象</span></span><br><span class="line">            book_queryset = Book.objects.<span class="built_in">all</span>()</span><br><span class="line">            <span class="comment"># 再去实例化对象</span></span><br><span class="line">            book_ser = BookSerialezer(book_queryset, many=<span class="literal">True</span>)</span><br><span class="line">            <span class="comment"># 字典更新</span></span><br><span class="line">            response_msg[<span class="string">&#x27;data&#x27;</span>] = book_ser.data</span><br><span class="line">            <span class="keyword">return</span> Response(response_msg)</span><br></pre></td></tr></table></figure>

<h2 id="五、新增数据"><a href="#五、新增数据" class="headerlink" title="五、新增数据"></a>五、新增数据</h2><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># urls.py</span></span><br><span class="line">    <span class="keyword">from</span> django.conf.urls <span class="keyword">import</span> url</span><br><span class="line">    <span class="keyword">from</span> django.contrib <span class="keyword">import</span> admin</span><br><span class="line">    <span class="keyword">from</span> app01 <span class="keyword">import</span> views</span><br><span class="line">    urlpatterns = [</span><br><span class="line">        url(<span class="string">r&#x27;^books/&#x27;</span>, views.BooksViews.as_view())</span><br><span class="line">    ]</span><br><span class="line">    </span><br><span class="line"><span class="comment"># views.py</span></span><br><span class="line">    <span class="class"><span class="keyword">class</span> <span class="title">BooksViews</span>(<span class="params">APIView</span>):</span></span><br><span class="line">        <span class="function"><span class="keyword">def</span> <span class="title">post</span>(<span class="params">self, request</span>):</span></span><br><span class="line">            <span class="comment"># 建立返回字典</span></span><br><span class="line">            response_msg = &#123;<span class="string">&#x27;status&#x27;</span>: <span class="number">200</span>, <span class="string">&#x27;msg&#x27;</span>: <span class="string">&#x27;成功&#x27;</span>&#125;</span><br><span class="line">            <span class="comment"># 建立书本对象</span></span><br><span class="line">            book_ser = BookSerialezer(data=request.data)</span><br><span class="line">            <span class="comment"># 检测数据格式</span></span><br><span class="line">            <span class="keyword">if</span> book_ser.is_valid():</span><br><span class="line">                book_ser.save()</span><br><span class="line">                response_msg[<span class="string">&#x27;data&#x27;</span>] = book_ser.data</span><br><span class="line">            <span class="keyword">else</span>:</span><br><span class="line">                response_msg[<span class="string">&#x27;status&#x27;</span>] = <span class="number">201</span></span><br><span class="line">                response_msg[<span class="string">&#x27;msg&#x27;</span>] = <span class="string">&#x27;数据校验不合格&#x27;</span></span><br><span class="line">                response_msg[<span class="string">&#x27;data&#x27;</span>] = book_ser.errors</span><br><span class="line">            <span class="keyword">return</span> Response(response_msg)</span><br><span class="line"></span><br><span class="line"><span class="comment"># 在应用下面创建一个py文件，名字任意</span></span><br><span class="line">	<span class="keyword">from</span> rest_framework.exceptions <span class="keyword">import</span> ValidationError</span><br><span class="line">    <span class="keyword">from</span> rest_framework <span class="keyword">import</span> serializers</span><br><span class="line">    <span class="keyword">from</span> app01.models <span class="keyword">import</span> Book</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">    <span class="class"><span class="keyword">class</span> <span class="title">BookSerialezer</span>(<span class="params">serializers.Serializer</span>):</span></span><br><span class="line">        <span class="function"><span class="keyword">def</span> <span class="title">create</span>(<span class="params">self, validated_data</span>):</span></span><br><span class="line">            instance = Book.objects.create(**validated_data)</span><br><span class="line">            <span class="keyword">return</span> instance</span><br><span class="line"></span><br></pre></td></tr></table></figure>

<h2 id="六、删除一个数据"><a href="#六、删除一个数据" class="headerlink" title="六、删除一个数据"></a>六、删除一个数据</h2><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># urls.py</span></span><br><span class="line">    <span class="keyword">from</span> django.conf.urls <span class="keyword">import</span> url</span><br><span class="line">    <span class="keyword">from</span> django.contrib <span class="keyword">import</span> admin</span><br><span class="line">    <span class="keyword">from</span> app01 <span class="keyword">import</span> views</span><br><span class="line">    urlpatterns = [</span><br><span class="line">        url(<span class="string">r&#x27;^books/&#x27;</span>, views.BooksViews.as_view())</span><br><span class="line">    ]</span><br><span class="line">    </span><br><span class="line"><span class="comment"># views.py</span></span><br><span class="line">    <span class="class"><span class="keyword">class</span> <span class="title">BookViews</span>(<span class="params">APIView</span>):</span></span><br><span class="line">        <span class="function"><span class="keyword">def</span> <span class="title">delete</span>(<span class="params">self, request, pk</span>):</span></span><br><span class="line">            <span class="comment"># 建立返回字典</span></span><br><span class="line">            response_msg = &#123;<span class="string">&#x27;status&#x27;</span>: <span class="number">200</span>, <span class="string">&#x27;msg&#x27;</span>: <span class="string">&#x27;成功&#x27;</span>&#125;</span><br><span class="line">            Book.objects.<span class="built_in">filter</span>(pk=pk).delete()</span><br><span class="line">            <span class="keyword">return</span> Response(response_msg)</span><br><span class="line"></span><br></pre></td></tr></table></figure>

<h2 id="七、分装返回字典"><a href="#七、分装返回字典" class="headerlink" title="七、分装返回字典"></a>七、分装返回字典</h2><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br></pre></td><td class="code"><pre><span class="line"><span class="string">&quot;&quot;&quot;</span></span><br><span class="line"><span class="string">	在应用下创建一个py文件，名字任取</span></span><br><span class="line"><span class="string">	然后创建一个类</span></span><br><span class="line"><span class="string">	......</span></span><br><span class="line"><span class="string">&quot;&quot;&quot;</span></span><br><span class="line"></span><br><span class="line"><span class="number">1.</span> 代码演示</span><br><span class="line">    <span class="comment"># utils.py</span></span><br><span class="line">        <span class="class"><span class="keyword">class</span> <span class="title">MyResponse</span>():</span></span><br><span class="line">            <span class="function"><span class="keyword">def</span> <span class="title">__init__</span>(<span class="params">self</span>):</span></span><br><span class="line">                self.status = <span class="number">200</span></span><br><span class="line">                self.msg = <span class="string">&#x27;成功&#x27;</span></span><br><span class="line"></span><br><span class="line"><span class="meta">            @property</span></span><br><span class="line">            <span class="function"><span class="keyword">def</span> <span class="title">get_dir</span>(<span class="params">self</span>):</span></span><br><span class="line">                <span class="keyword">return</span> self.__dict__</span><br><span class="line"></span><br><span class="line">    <span class="comment"># views.py</span></span><br><span class="line">        <span class="class"><span class="keyword">class</span> <span class="title">BooksViews</span>(<span class="params">APIView</span>):</span></span><br><span class="line">        <span class="function"><span class="keyword">def</span> <span class="title">get</span>(<span class="params">self, request</span>):</span></span><br><span class="line">            <span class="comment"># 建立返回字典</span></span><br><span class="line">            response_dir = utils.MyResponse()</span><br><span class="line">            <span class="comment"># 建立书本对象</span></span><br><span class="line">            book_queryset = Book.objects.<span class="built_in">all</span>()</span><br><span class="line">            <span class="comment"># 再去实例化对象</span></span><br><span class="line">            book_ser = BookSerialezer(book_queryset, many=<span class="literal">True</span>)</span><br><span class="line">            <span class="comment"># 字典更新</span></span><br><span class="line">            response_dir.data = book_ser.data</span><br><span class="line">            <span class="keyword">return</span> Response(response_dir.get_dir)</span><br><span class="line"></span><br></pre></td></tr></table></figure>

<h2 id="八、模型类序列化器"><a href="#八、模型类序列化器" class="headerlink" title="八、模型类序列化器"></a>八、模型类序列化器</h2><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><span class="line"><span class="class"><span class="keyword">class</span> <span class="title">BookModelSerializer</span>(<span class="params">serializers.ModelSerializer</span>):</span></span><br><span class="line">    <span class="class"><span class="keyword">class</span> <span class="title">Meta</span>:</span></span><br><span class="line">        model=Book  <span class="comment"># 对应上models.py中的模型</span></span><br><span class="line">        fields=<span class="string">&#x27;__all__&#x27;</span></span><br><span class="line">        fields=(<span class="string">&#x27;name&#x27;</span>,<span class="string">&#x27;price&#x27;</span>,<span class="string">&#x27;id&#x27;</span>,<span class="string">&#x27;author&#x27;</span>) <span class="comment"># 只序列化指定的字段 要么列表 要么元组</span></span><br><span class="line">        exclude=(<span class="string">&#x27;name&#x27;</span>,) <span class="comment">#跟fields不能都写，写谁，就表示排除谁</span></span><br><span class="line">        read_only_fields=(<span class="string">&#x27;price&#x27;</span>,)</span><br><span class="line">        write_only_fields=(<span class="string">&#x27;id&#x27;</span>,) <span class="comment">#弃用了，使用extra_kwargs</span></span><br><span class="line">        extra_kwargs = &#123;  <span class="comment"># 类似于这种形式name=serializers.CharField(max_length=16,min_length=4)</span></span><br><span class="line">            <span class="string">&#x27;price&#x27;</span>: &#123;<span class="string">&#x27;write_only&#x27;</span>: <span class="literal">True</span>&#125;,</span><br><span class="line">        &#125;</span><br><span class="line">        </span><br><span class="line"><span class="comment"># 其他使用一模一样</span></span><br><span class="line"><span class="comment"># 不需要重写create和updata方法了</span></span><br></pre></td></tr></table></figure>

<h2 id="九、many源码分析"><a href="#九、many源码分析" class="headerlink" title="九、many源码分析"></a>九、many源码分析</h2><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># 序列化多条，需要传many=True</span></span><br><span class="line">    book_ser=BookModelSerializer(books,many=<span class="literal">True</span>)</span><br><span class="line">    book_one_ser=BookModelSerializer(book)</span><br><span class="line">    <span class="built_in">print</span>(<span class="built_in">type</span>(book_ser))</span><br><span class="line">	<span class="comment">#&lt;class &#x27;rest_framework.serializers.ListSerializer&#x27;&gt;</span></span><br><span class="line">    <span class="built_in">print</span>(<span class="built_in">type</span>(book_one_ser))</span><br><span class="line">    <span class="comment">#&lt;class &#x27;app01.ser.BookModelSerializer&#x27;&gt;</span></span><br><span class="line"><span class="string">&quot;&quot;&quot;</span></span><br><span class="line"><span class="string">    对象的生成--》先调用类的__new__方法，生成空对象</span></span><br><span class="line"><span class="string">    对象=类名(name=lqz)，触发类的__init__()</span></span><br><span class="line"><span class="string">    类的__new__方法控制对象的生成</span></span><br><span class="line"><span class="string">&quot;&quot;&quot;</span></span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">def</span> <span class="title">__new__</span>(<span class="params">cls, *args, **kwargs</span>):</span></span><br><span class="line">    <span class="keyword">if</span> kwargs.pop(<span class="string">&#x27;many&#x27;</span>, <span class="literal">False</span>):</span><br><span class="line">        <span class="keyword">return</span> cls.many_init(*args, **kwargs)</span><br><span class="line">    <span class="comment"># 没有传many=True,走下面，正常的对象实例化</span></span><br><span class="line">    <span class="keyword">return</span> <span class="built_in">super</span>().__new__(cls, *args, **kwargs)</span><br></pre></td></tr></table></figure>

<h2 id="十、Serializer高级用法"><a href="#十、Serializer高级用法" class="headerlink" title="十、Serializer高级用法"></a>十、Serializer高级用法</h2><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># source的使用</span></span><br><span class="line">	<span class="number">1</span> 可以改字段名字  xxx=serializers.CharField(source=<span class="string">&#x27;title&#x27;</span>)</span><br><span class="line">    <span class="number">2</span> 可以.跨表publish=serializers.CharField(source=<span class="string">&#x27;publish.email&#x27;</span>)</span><br><span class="line">    <span class="number">3</span> 可以执行方法pub_date=serializers.CharField(source=<span class="string">&#x27;test&#x27;</span>) test是Book表模型中的方法</span><br><span class="line">    </span><br><span class="line"></span><br><span class="line"><span class="comment"># SerializerMethodField(）的使用</span></span><br><span class="line">	<span class="number">1</span> 它需要有个配套方法，方法名叫get_字段名，返回值就是要显示的东西</span><br><span class="line">    authors=serializers.SerializerMethodField() <span class="comment">#它需要有个配套方法，方法名叫get_字段名，返回值就是要显示的东西</span></span><br><span class="line">    <span class="function"><span class="keyword">def</span> <span class="title">get_authors</span>(<span class="params">self,instance</span>):</span></span><br><span class="line">        <span class="comment"># book对象</span></span><br><span class="line">        authors=instance.authors.<span class="built_in">all</span>()  <span class="comment"># 取出所有作者</span></span><br><span class="line">        ll=[]</span><br><span class="line">        <span class="keyword">for</span> author <span class="keyword">in</span> authors:</span><br><span class="line">            ll.append(&#123;<span class="string">&#x27;name&#x27;</span>:author.name,<span class="string">&#x27;age&#x27;</span>:author.age&#125;)</span><br><span class="line">        <span class="keyword">return</span> ll</span><br></pre></td></tr></table></figure>


            </div>

            <!-- Post Comments -->
            
    <!-- 使用 DISQUS_CLICK -->
<div id="disqus-comment">
    <div id="disqus_thread"></div>

<!-- add animation -->
<style>
	.disqus_click_btn {
            line-height: 30px;
            margin: 0;
            min-width: 50px;
            padding: 0 14px;
            display: inline-block;
            font-family: "Roboto", "Helvetica", "Arial", sans-serif;
            font-size: 14px;
            font-weight: 400;
            text-transform: uppercase;
            letter-spacing: 0;
            overflow: hidden;
            will-change: box-shadow;
            transition: box-shadow .2s cubic-bezier(.4, 0, 1, 1), background-color .2s cubic-bezier(.4, 0, .2, 1), color .2s cubic-bezier(.4, 0, .2, 1);
            outline: 0;
            cursor: pointer;
            text-decoration: none;
            text-align: center;
            vertical-align: middle;
            border: 0;
            background: rgba(158, 158, 158, .2);
            box-shadow: 0 2px 2px 0 rgba(0, 0, 0, .14), 0 3px 1px -2px rgba(0, 0, 0, .2), 0 1px 5px 0 rgba(0, 0, 0, .12);
            color: #fff;
            background-color: #7EC0EE;
            text-shadow: 0
        }
</style>
	
<div class="btn_click_load" id="disqus_bt"> 
    <button class="disqus_click_btn">点击查看评论</button>
</div>

<!--
<script type="text/javascript">
$('.btn_click_load').click(function() {
    /* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
    var disqus_shortname = 'http-miccall-tech'; // required: replace example with your forum shortname

    /* * * DON'T EDIT BELOW THIS LINE * * */
    (function() {
      var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
      dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js';
      (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
    })();

    document.getElementById('disqus_bt').style.display = "none";
});
</script>
-->
<script type="text/javascript">
    var disqus_config = function () {
        this.page.url = 'https://gitee.com/AmeX/amelin-ting.git/2018/05/29/drf------Serializer/';  // Replace PAGE_URL with your page's canonical URL variable
        this.page.identifier = 'https://gitee.com/AmeX/amelin-ting.git/2018/05/29/drf------Serializer/'; // Replace PAGE_IDENTIFIER with your page's unique identifier variable
    };
</script>

<script type="text/javascript">
    $('.btn_click_load').click(function() {  //click to load comments
        (function() { // DON'T EDIT BELOW THIS LINE
            var d = document;
            var s = d.createElement('script');
            s.src = '//http-miccall-tech.disqus.com/embed.js';
            s.setAttribute('data-timestamp', + new Date());
            (d.head || d.body).appendChild(s);
        })();
        $('.btn_click_load').css('display','none');
    });
</script>
</div>
<style>
    #disqus-comment{
        background-color: #eee;
        padding: 2pc;
    }
</style>


        </div>
        <!-- Copyright 版权 start -->
                <div id="copyright">
            <ul>
                <li>&copy;Powered By <a target="_blank" rel="noopener" href="https://hexo.io/zh-cn/" style="border-bottom: none;">hexo</a></li>
                <li>Design: <a target="_blank" rel="noopener" href="http://miccall.tech " style="border-bottom: none;">miccall</a></li>
            </ul>
            
                <span id="busuanzi_container_site_pv">本站总访问量<span id="busuanzi_value_site_pv"></span>次</span>
			
        </div>
    </div>
</body>



 	
</html>
